/*join.c*/
#include <pthread.h>
#include <stdio.h>
void *t1_exe(void *arg)
{
    printf("The first thread: \n");
    int i;
    for (i = 1; i < 6; i++)
        printf("%d\n", i);
}
void *t2_exe(void *arg)
{
    int i;
    pthread_join(*(pthread_t *)arg, NULL);
    printf("The second thread: \n");
    for (i = 6; i < 11; i++)
        printf("%d\n", i);
}
void main()
{
    pthread_t pid1, pid2;
    int error1, error2;
    error1 = pthread_create(&pid1, NULL, t1_exe, NULL);
    error2 = pthread_create(&pid2, NULL, t2_exe, (void *)&pid1);
    if (error1 != 0 || error2 != 0)
    {
        printf("pthread_create failed ");
        return;
    }
    pthread_join(pid2, NULL);
    return;
}